<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=1180,initial-scale=0,user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="renderer" content="webkit">
    <script type="text/javascript" src="./crypto-js.js"></script>
    <title>首页</title>
</head>
<body>
<script type="text/javascript">
    function aesEncrypt(value, key) {
        key = CryptoJS.enc.Utf8.parse(key);
        let encryptedData = CryptoJS.AES.encrypt(value, key, {
            mode: CryptoJS.mode.ECB,
            padding: CryptoJS.pad.Pkcs7
        });
        encryptedData = encryptedData.ciphertext.toString();
        return CryptoJS.enc.Hex.parse(encryptedData).toString();
    }

    function aesDecrypt(value, key) {
        key = CryptoJS.enc.Utf8.parse(key);
        let hexStr = CryptoJS.enc.Hex.parse(value);
        let encryptedBase64Str = CryptoJS.enc.Base64.stringify(hexStr);
        let decryptedData = CryptoJS.AES.decrypt(encryptedBase64Str, key, {
            mode: CryptoJS.mode.ECB,
            padding: CryptoJS.pad.Pkcs7
        });
        return decryptedData.toString(CryptoJS.enc.Utf8);
    }

    let value = "1228";
    let key = "0000000000135246";
    encryptedData = aesEncrypt(value, key);
    console.log("加密前：" + value);
    console.log("加密后：" + encryptedData);
    console.log("解密后：" + aesDecrypt(encryptedData, key));
    console.log("解密后：" + CryptoJS.HmacSHA256("device=7802602f734eaff74de55e0f3c9da3acb41e394e&pageNo=1&pageSize=50&partnerId=10004&sessionId=A7E1080F08AA6AF4DED1DE32D8CE38D4A4F1F0BDFB66AF2F2348B8jj3Voxctxu&timeRange=day&timestamp=1663157420853","aek3cier"));
</script>
</body>
</html>